from race.Player import *
import logging.config
from threading import Thread

logging.config.fileConfig('./util/logging.conf')
log = logging.getLogger("example")

"""
    子类描述：
        1、战士坦克类
"""


class TankWarrior(Player):

    def on_keyboard_press_son_before_thread(self, key):
        log.debug("on_keyboard_press_son_before_thread 1:进入了函数")
        # 有些按键是直接终止别人的，继续自己的，有些不是这样的，因此要区别对待【排列组合，情况非常多】/【也要超级符合每个职业的操作习惯】
        if key in (
                Key.f1, Key.f2, Key.f3, Key.f4, Key.f5, Key.f6, Key.f7, Key.f8, Key.f9, Key.f10, Key.f11,
                Key.f12):
            pass
        elif key == Key.enter:
            pass
        elif key == Key.space:
            pass
        elif key == Key.alt_l:
            pass
        elif key == Key.ctrl_l:
            pass
        elif key == Key.caps_lock:
            pass
        elif key == Key.shift_l:
            pass
        elif key.char == 'a':
            # 不终止别人，后面让只允许一个线程执行的逻辑来顺序排
            # ★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|★★★★★★|
            # 并行并发执行的折中方案【通过触发其他按键，这样的好处是线程池统一管理了】
            pass
        elif key.char == 'z':
            pass
        elif key.char == 'q':
            pass
        elif key.char == 'w':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'r':
            # 终止掉别人
            # interruptAllByForce()
            pass
        elif key.char == 'g':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'x':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'v':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'h':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'c':
            # 终止掉别人
            self.interruptAllByForce()
        elif key.char == 'e':
            pass
        elif key.char == 's':
            pass
        elif key.char == 'd':
            pass
        elif key.char == 'f':
            pass
        elif key.char == 'b':
            pass

    def a(self):
        # 父类的方法先执行（或者后续看看是不是就直接用之类覆盖之后的方法）
        self.startScheduler1()  # 调用 CallBackScheduler1
        self.startScheduler2()  # 调用 CallBackScheduler2
        self.startScheduler3()  # 调用 CallBackScheduler3
        self.startScheduler4()  # 调用 CallBackScheduler3
        self.startScheduler5()  # 调用 CallBackScheduler3
        self.startScheduler6()  # 调用 CallBackScheduler6

    def CallBackScheduler1(self):
        while self.ui.stopLoop == False:
            # 盾牌猛击CD
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X1, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'small', '1', 0.06, 5, self.ELSEKEY_1 ,self.DEBUG_CLOSE)

            # self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X2, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
            #                                   self.WABloodBarDeltaY,
            #                                   self.WA_SQUARE_ZFX_AvgColor,
            #                                   self.RED, 'small', '2', 0.06, 3, self.ELSEKEY_1 ,self.DEBUG_CLOSE)
            sleep(0.1)
            # 雷霆一击
            self.click(self.kb, '2', 4)
            sleep(0.1)
            # 乘胜追击，加血。临时
            # self.click(self.kb, '8', 3)
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.5, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '8', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            sleep(0.1)

    def CallBackScheduler2(self):
        while self.ui.stopLoop == False:
            # 盾牌格挡
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.95, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.GREEN, 'small', '4', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 盾牌格挡
            avgColorNumber = self.pubAvgColorNoTrigger(self.WA_SQUARE_ZFX_X3, self.WA_SQUARE_ZFX,
                                                       self.WABloodBarDeltaX,
                                                       self.WABloodBarDeltaY, self.GREEN, 0.06)
            if avgColorNumber < self.WA_SQUARE_ZFX_AvgColor:
                # 无视痛苦
                self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.95, self.WABloodBarY,
                                                      self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                      self.WABloodBarAvgColor, self.RED, 'small', '3', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            else:
                self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.85, self.WABloodBarY,
                                                      self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                      self.WABloodBarAvgColor, self.RED, 'small', '3', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            sleep(0.1)
            # 回血
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.8, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '\\', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)

    def CallBackScheduler3(self):
        while self.ui.stopLoop == False:
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'i', 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)

            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.5, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'k', 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)

            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.4, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', Key.f10, 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)

            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.35, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 't', 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)
            # 破胆怒吼
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.35, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'o', 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)

    def CallBackScheduler4(self):
        while self.ui.stopLoop == False:
            # dps，复仇
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.9, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'big', Key.f8, 0.06, 5, self.ELSEKEY_1, self.DEBUG_CLOSE)
            # 挫志怒吼
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.8, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'n', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            sleep(0.1)
            # 手雷饰品
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.5, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', 'p', 0.06, 4, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 复仇CD，好了免费，DPS
            self.pubAvgColorTiggerKeyBuffMode(self.WA_SQUARE_ZFX_X4, self.WA_SQUARE_ZFX, self.WABloodBarDeltaX,
                                              self.WABloodBarDeltaY,
                                              self.WA_SQUARE_ZFX_AvgColor,
                                              self.RED, 'big', Key.f8, 0.06, 3, self.ELSEKEY_1 ,self.DEBUG_CLOSE)
            sleep(0.1)

    def CallBackScheduler5(self):
        while self.ui.stopLoop == False:
            # 盾牌格挡
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.7, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '4', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            # 无视痛苦
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.7, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', '3', 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            sleep(0.1)
            # 术士石头
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', Key.f4, 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)

            # 减伤饰品
            self.pubAvgColorTiggerKeyBloodBarMode(self.WABloodBarX + self.WABloodBarWidth * 0.6, self.WABloodBarY,
                                                  self.WABloodBarDeltaX, self.WABloodBarDeltaY,
                                                  self.WABloodBarAvgColor, self.RED, 'small', Key.f3, 0.06, 6, self.ELSEKEY_1, self.DEBUG_CLOSE)
            sleep(0.1)

    def CallBackScheduler6(self):
        while self.ui.stopLoop == False:
            sleep(0.1)
            self.click(self.kb, '5', 2)
            self.click(self.kb, '7', 2)
            sleep(0.1)
            self.click(self.kb, Key.f7, 2)
            self.click(self.kb, 'l', 2)
            sleep(0.1)

    def on_mouse_click_son_before_thread(self, x, y, button, pressed):
        # 在鼠标点击，终止和打断其他动作（有些职业需要，有些不需要）??????????
        pass
        return

    def space(self):
        for i in range(1, 4):
            self.click(self.kb, ';', 2)
            sleep(0.1)

        # 打断后的继续
        # self.click(self.kb, 'a', 1)
        return

    def x(self):
        for i in range(1, 4):
            self.click(self.kb, '[', 2)
            sleep(0.1)

        # 打断后的继续
        self.click(self.kb, 'a', 1)
        return

    def mouseUp(self, x, y):
        # 战士的弱点，魔法盾
        log.debug('★鼠标向上滚，需要开始执行的内容★')
        for i in range(1, 20):
            self.click(self.kb, Key.f9, 2)
            sleep(0.01)
        log.debug('★鼠标向上滚，需要over执行的内容★')
        return


if __name__ == '__main__':
    pass
